1.Why?Fflush (stdin)If yes, first check the following program: # includeStdio. h>Int main (void) {int I; for (;) {fputs ("Please input an integer:", stdout); scanf ("% d", & I ); printf ("% d/N", I);} return 0;} this program will first prompt the
For C-language beginners, the fflush (stdin) function is interpreted as a system function that empties the input buffer, which is once almost half the story, with the progress of computer science, the gradual improvement in the process of learning
1. Why is fflush (stdin) incorrect?
First, check the following program:
# Include
Int main (void)
{
Int I;
For (;;){
Fputs ("Please input an integer:", stdout );
Scanf ("% d", & I );
Printf ("% d/N", I );
}
Return 0;
}
This program will
1. Why is fflush (stdin) incorrect?
First, check the following program:
# Include Int main (void){Int I;
For (;;){Fputs ("Please input an integer:", stdout );Scanf ("% d", & I );Printf ("% d/N", I );}
Return 0;}
This program will first prompt the
1.Why?
Fflush (stdin)Yes
First, check the following program:
# IncludeStdio. h>
Int main (void)
{
Int I;
For (;;){
Fputs ("Please input an integer:", stdout );
Scanf ("% d", & I );
Printf ("% d/N", I );
}
Return 0;
}
This program will first
1. Why Fflush (stdin) is wrong
First, look at the following programs:
include int main( void ) { int i; for ( ;;) { fputs("Please input an integer: ", stdout); scanf("%d", &i); printf("%d\n", i); } return 0; }
The program first
1.Why?Fflush (stdin)Yes
First, check the following program:
# IncludeStdio. h>
Int main (void)
{
Int I;
For (;;){
Fputs ("Please input an integer:", stdout );
Scanf ("% d", & I );
Printf ("% d \ n", I );
}
Return 0;
}
This program will first
Fflush (stdin) has never been defined in the C and C ++ standards ). Some people may say, "but I used fflush (stdin) to solve this problem. How can you say it is wrong ?" Indeed, some compilers (such as vc6) Support fflush (stdin) to clear the input
Transferred from: http://blog.csdn.net/yeyuangen/article/details/6743416Fflush (stdin) cleans up the standard input stream and discards the excess data that is still not saved.Fflush (stdout): empties the output buffer and outputs the buffer
1.fflush (stdin):
Role: Clean up the standard input stream and throw away the excess data that has not been saved.
Such as:
int main ()
{
int num;
Char str[10];
cin>>num;
cout>str;
cout
Get an integer
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.